package com.yao.mall.controller;

import com.yao.mall.common.ErrorCode;
import com.yao.mall.common.Result;
import com.yao.mall.config.BusinessException;
import com.yao.mall.model.vo.GoodsSkuVO;
import com.yao.mall.service.GoodsSkuService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author jiahua.yao
 * @version 1.0
 * @description 商品规格类控制层
 * @date 2024/3/12 17:19
 */
@RestController
@RequestMapping("/goodsSku")
@Tag(name = "商品规格相关接口")
public class GoodsSkuController {
    @Resource
    private GoodsSkuService goodsSkuService;

    @GetMapping("/{spuId}")
    @Operation(summary = "获取某个商品的规格信息")
    public Result<List<GoodsSkuVO>> getGoodsSku(@PathVariable("spuId") Long spuId) {
        if(spuId == null){
            throw new BusinessException(ErrorCode.PARAMS_ERROR,"缺少必要条件");
        }
        List<GoodsSkuVO> goodsSkuVO = goodsSkuService.getGoodsSku(spuId,null,null);
        return Result.success(goodsSkuVO);
    }

    /*@PostMapping("/add")
    //为某个商品添加商品规格
    public Result<Boolean> addGoodsSku(GoodsSkuRequest goodsSkuRequest) {
        Boolean aBoolean = goodsSkuService.addGoodsSku(goodsSkuRequest);
        return Result.success(aBoolean);
    }*/
/*
    @PutMapping("/updateBasic")
    //修改商品规格
    public Result<Boolean> updateBasic(@RequestBody GoodsSkuRequest brandRequest) {
        Boolean aBoolean = goodsSkuService.updateGoodsSkuBasic(brandRequest);
        return Result.success(aBoolean);
    }

    @DeleteMapping("/{id}")
    //删除商品规格
    public Result<Boolean> deleteGoodsSku(@PathVariable Integer id) {
        Boolean aBoolean = goodsSkuService.deleteGoodsSku(id);
        return Result.success(aBoolean);
    }
*/


}
